#ifndef _CALLBACK_H__
#define _CALLBACK_H__

class ICallbackStringParam
{
	public:
		virtual void Execute(const std::string& param) const = 0;
};

/**
 * Use this template whenever you need to invoke a method of a concrete instance of a class that admits
 * a std::string as a parameter; this is: a callback. You must use 'SetCallback' to set it up or 'Execute'
 * won't have any effect.
 * @note: The base class of this class is a helper to pass the callback to any other functions that are
 *		agnostic about the concrete template specialization.
 */
template <class C>
class CallbackStringParam : public ICallbackStringParam
{
	public:
		
		CallbackStringParam() : m_function(0){}

		typedef void (C::*Function)(const std::string& param);
	    
		virtual void Execute(const std::string& param) const 
		{
			if (m_function) 
				(m_instance->*m_function)(param);
		}

		void SetCallback (C* instance, Function function)
		{
			m_instance = instance;
			m_function = function;
		}

	private:
		C* m_instance;
		Function m_function;
};

#endif